home *** CD-ROM | disk | FTP | other *** search
Wrap
package com.sun.java.swing.plaf.basic; import com.sun.java.swing.BorderFactory; import com.sun.java.swing.KeyStroke; import com.sun.java.swing.LookAndFeel; import com.sun.java.swing.UIDefaults; import com.sun.java.swing.border.BevelBorder; import com.sun.java.swing.border.LineBorder; import com.sun.java.swing.plaf.BorderUIResource; import com.sun.java.swing.plaf.ColorUIResource; import com.sun.java.swing.plaf.FontUIResource; import com.sun.java.swing.text.JTextComponent; import java.awt.Color; import java.io.Serializable; public abstract class BasicLookAndFeel extends LookAndFeel implements Serializable { public UIDefaults getDefaults() { UIDefaults table = new UIDefaults(); this.initClassDefaults(table); this.initSystemColorDefaults(table); this.initComponentDefaults(table); return table; } protected void initClassDefaults(UIDefaults table) { String basicPackageName = "com.sun.java.swing.plaf.basic."; Object[] uiDefaults = new Object[]{"ButtonUI", basicPackageName + "BasicButtonUI", "CheckBoxUI", basicPackageName + "BasicCheckBoxUI", "ColorChooserUI", basicPackageName + "BasicColorChooserUI", "MenuBarUI", basicPackageName + "BasicMenuBarUI", "MenuUI", basicPackageName + "BasicMenuUI", "MenuItemUI", basicPackageName + "BasicMenuItemUI", "CheckBoxMenuItemUI", basicPackageName + "BasicCheckBoxMenuItemUI", "RadioButtonMenuItemUI", basicPackageName + "BasicRadioButtonMenuItemUI", "RadioButtonUI", basicPackageName + "BasicRadioButtonUI", "ToggleButtonUI", basicPackageName + "BasicToggleButtonUI", "PopupMenuUI", basicPackageName + "BasicPopupMenuUI", "ProgressBarUI", basicPackageName + "BasicProgressBarUI", "ScrollBarUI", basicPackageName + "BasicScrollBarUI", "ScrollPaneUI", basicPackageName + "BasicScrollPaneUI", "SplitPaneUI", basicPackageName + "BasicSplitPaneUI", "SliderUI", basicPackageName + "BasicSliderUI", "SpinnerUI", basicPackageName + "BasicSpinnerUI", "SeparatorUI", basicPackageName + "BasicSeparatorUI", "TabbedPaneUI", basicPackageName + "BasicTabbedPaneUI", "TextAreaUI", basicPackageName + "BasicTextAreaUI", "TextFieldUI", basicPackageName + "BasicTextFieldUI", "PasswordFieldUI", basicPackageName + "BasicPasswordFieldUI", "TextPaneUI", basicPackageName + "BasicTextPaneUI", "EditorPaneUI", basicPackageName + "BasicEditorPaneUI", "TreeUI", basicPackageName + "BasicTreeUI", "LabelUI", basicPackageName + "BasicLabelUI", "ListUI", basicPackageName + "BasicListUI", "ToolBarUI", basicPackageName + "BasicToolBarUI", "ToolTipUI", basicPackageName + "BasicToolTipUI", "ComboBoxUI", basicPackageName + "BasicComboBoxUI", "TableUI", basicPackageName + "BasicTableUI", "TableHeaderUI", basicPackageName + "BasicTableHeaderUI", "InternalFrameUI", basicPackageName + "BasicInternalFrameUI", "StandardDialogUI", basicPackageName + "BasicStandardDialogUI", "DesktopPaneUI", basicPackageName + "BasicDesktopPaneUI", "DesktopIconUI", basicPackageName + "BasicDesktopIconUI", "OptionPaneUI", basicPackageName + "BasicOptionPaneUI"}; table.putDefaults(uiDefaults); } protected void initComponentDefaults(UIDefaults table) { FontUIResource dialogPlain12 = new FontUIResource("Dialog", 0, 12); FontUIResource serifPlain12 = new FontUIResource("Serif", 0, 12); FontUIResource sansSerifPlain12 = new FontUIResource("SansSerif", 0, 12); FontUIResource monospacedPlain12 = new FontUIResource("Monospaced", 0, 12); FontUIResource dialogBold12 = new FontUIResource("Dialog", 1, 12); ColorUIResource red = new ColorUIResource(Color.red); ColorUIResource black = new ColorUIResource(Color.black); ColorUIResource white = new ColorUIResource(Color.white); ColorUIResource yellow = new ColorUIResource(Color.yellow); ColorUIResource gray = new ColorUIResource(Color.gray); ColorUIResource lightGray = new ColorUIResource(Color.lightGray); ColorUIResource darkGray = new ColorUIResource(Color.darkGray); ColorUIResource scrollBarTrack = new ColorUIResource(224, 224, 224); ColorUIResource treeSelection = new ColorUIResource(Color.red); ColorUIResource menuItemPressedBackground = new ColorUIResource(0, 0, 128); ColorUIResource menuItemPressedForeground = new ColorUIResource(255, 255, 255); Object listCellRendererActiveValue = new 1(); Object comboBoxRendererActiveValue = new 2(); Object comboBoxEditorActiveValue = new 3(); Object scrollPaneBorder = new 4(); Object tableScrollPaneBorder = new BorderUIResource(new BevelBorder(1)); Object newFolderIcon = new 5(); Object upFolderIcon = new 6(); Object homeFolderIcon = new 7(); Object detailsViewIcon = new 8(); Object listViewIcon = new 9(); Object directoryIcon = new 10(); Object fileIcon = new 11(); Object computerIcon = new 12(); Object hardDriveIcon = new 13(); Object floppyDriveIcon = new 14(); Object multilineTextBorder = new 15(); Object fieldTextBorder = new 16(); JTextComponent.KeyBinding[] fieldBindings = new JTextComponent.KeyBinding[]{new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(10, 0), "notify-field-accept")}; JTextComponent.KeyBinding[] multilineBindings = new JTextComponent.KeyBinding[]{new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(38, 0), "caret-up"), new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(40, 0), "caret-down"), new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(33, 0), "page-up"), new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(34, 0), "page-down"), new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(10, 0), "insert-break"), new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(9, 0), "insert-tab")}; Object caretBlinkRate = new 17(); Object toolTipBorder = new 18(); Object progressBarBorder = new BorderUIResource(new LineBorder(Color.green, 2)); Object buttonBorder = new 19(); Object buttonToggleBorder = new 20(); Object radioButtonBorder = new 21(); Object internalFrameBorder = new 22(); Object menuMarginBorder = new 23(); Object menuBarBorder = new 24(); Object popupMenuBorder = new 25(); Object titledBorderBorder = new 26(); Object toolBarBorder = new 27(); Object selectedColorBorder = new 28(); Object menuItemCheckIcon = new 29(); Object menuItemArrowIcon = new 30(); Object menuArrowIcon = new 31(); Object checkBoxIcon = new 32(); Object radioButtonIcon = new 33(); Object checkBoxMenuItemIcon = new 34(); Object radioButtonMenuItemIcon = new 35(); Object optionPaneBorder = new 36(); new 37(); Object focusCellHighlightBorder = new BorderUIResource(new LineBorder(yellow)); Object splitPaneBorder = new BorderUIResource(new BasicSplitPaneUI.SplitBorder(table.getColor("controlHighlight"), table.getColor("controlDkShadow"))); Object[] defaults = new Object[]{"Desktop.background", table.get("desktop"), "Panel.background", table.get("control"), "Panel.foreground", table.get("textText"), "Panel.font", dialogPlain12, "Button.border", buttonBorder, "Button.background", table.get("control"), "Button.foreground", table.get("controlText"), "Button.focus", table.get("controlText"), "Button.font", dialogPlain12, "Button.pressed", table.get("control"), "ToggleButton.border", buttonToggleBorder, "ToggleButton.background", table.get("control"), "ToggleButton.foreground", table.get("controlText"), "ToggleButton.focus", table.get("controlText"), "ToggleButton.font", dialogPlain12, "ToggleButton.pressed", table.get("control"), "RadioButton.background", table.get("control"), "RadioButton.foreground", table.get("controlText"), "RadioButton.font", dialogPlain12, "RadioButton.icon", radioButtonIcon, "RadioButton.border", radioButtonBorder, "RadioButton.focus", black, "CheckBox.icon", checkBoxIcon, "CheckBox.focus", black, "RadioButtonMenuItem.icon", radioButtonMenuItemIcon, "CheckBoxMenuItem.icon", checkBoxMenuItemIcon, "MenuBar.border", menuBarBorder, "MenuBar.background", table.get("menu"), "MenuBar.foreground", table.get("menuText"), "MenuBar.font", dialogPlain12, "Menu.border", menuMarginBorder, "Menu.font", dialogPlain12, "Menu.foreground", table.get("menuText"), "Menu.background", table.get("menu"), "Menu.pressedForeground", menuItemPressedForeground, "Menu.pressedBackground", menuItemPressedBackground, "Menu.arrowIcon", menuArrowIcon, "MenuItem.border", menuMarginBorder, "MenuItem.borderPainted", Boolean.FALSE, "MenuItem.font", dialogPlain12, "MenuItem.foreground", table.get("menuText"), "MenuItem.background", table.get("menu"), "MenuItem.pressedForeground", menuItemPressedForeground, "MenuItem.pressedBackground", menuItemPressedBackground, "MenuItem.disabledForeground", null, "MenuItem.acceleratorFont", dialogPlain12, "MenuItem.acceleratorForeground", table.get("menuText"), "MenuItem.acceleratorPressedForeground", menuItemPressedForeground, "MenuItem.checkIcon", menuItemCheckIcon, "MenuItem.arrowIcon", menuItemArrowIcon, "PopupMenu.background", table.get("menu"), "PopupMenu.border", popupMenuBorder, "PopupMenu.foreground", table.get("menuText"), "PopupMenu.font", dialogPlain12, "Label.font", dialogPlain12, "Label.background", table.get("control"), "Label.foreground", table.get("controlText"), "Label.disabled", white, "Label.disabledShadow", table.get("controlShadow"), "List.selectionBackground", table.get("textHighlight"), "List.selectionForeground", table.get("textHighlightText"), "List.background", table.get("window"), "List.foreground", table.get("textText"), "List.focusCellHighlightBorder", focusCellHighlightBorder, "List.font", dialogPlain12, "List.cellRenderer", listCellRendererActiveValue, "List.border", null, "ComboBox.renderer", comboBoxRendererActiveValue, "ComboBox.editor", comboBoxEditorActiveValue, "ComboBox.background", white, "ComboBox.foreground", black, "ComboBox.selectedBackground", table.get("textHighlight"), "ComboBox.selectedForeground", table.get("textHighlightText"), "ComboBox.font", dialogPlain12, "ComboBox.disabledBackground", table.get("control"), "ComboBox.disabledForeground", table.get("textInactiveText"), "FileChooser.acceptAllFileFilterText", new String("All Files (*.*)"), "FileChooser.cancelButtonText", new String("Cancel"), "FileChooser.saveButtonText", new String("Save"), "FileChooser.openButtonText", new String("Open"), "FileChooser.updateButtonText", new String("Update"), "FileChooser.helpButtonText", new String("Help"), "FileChooser.cancelButtonToolTipText", new String("Abort file chooser dialog."), "FileChooser.saveButtonToolTipText", new String("Save selected file."), "FileChooser.openButtonToolTipText", new String("Open selected file."), "FileChooser.updateButtonToolTipText", new String("Update directory listing."), "FileChooser.helpButtonToolTipText", new String("FileChooser help."), "FileChooser.newFolderIcon", newFolderIcon, "FileChooser.upFolderIcon", upFolderIcon, "FileChooser.homeFolderIcon", homeFolderIcon, "FileChooser.detailsViewIcon", detailsViewIcon, "FileChooser.listViewIcon", listViewIcon, "FileView.directoryIcon", directoryIcon, "FileView.fileIcon", fileIcon, "FileView.computerIcon", computerIcon, "FileView.hardDriveIcon", hardDriveIcon, "FileView.floppyDriveIcon", floppyDriveIcon, "TextField.caretForeground", black, "TextField.caretBlinkRate", caretBlinkRate, "TextField.inactiveForeground", table.get("textInactiveText"), "TextField.selectionBackground", table.get("textHighlight"), "TextField.selectionForeground", table.get("textHighlightText"), "TextField.background", table.get("window"), "TextField.foreground", table.get("textText"), "TextField.font", sansSerifPlain12, "TextField.border", fieldTextBorder, "TextField.keyBindings", fieldBindings, "PasswordField.caretForeground", black, "PasswordField.caretBlinkRate", caretBlinkRate, "PasswordField.inactiveForeground", table.get("textInactiveText"), "PasswordField.selectionBackground", table.get("textHighlight"), "PasswordField.selectionForeground", table.get("textHighlightText"), "PasswordField.background", table.get("window"), "PasswordField.foreground", table.get("textText"), "PasswordField.font", monospacedPlain12, "PasswordField.border", fieldTextBorder, "PasswordField.keyBindings", fieldBindings, "TextArea.caretForeground", black, "TextArea.caretBlinkRate", caretBlinkRate, "TextArea.inactiveForeground", table.get("textInactiveText"), "TextArea.selectionBackground", table.get("textHighlight"), "TextArea.selectionForeground", table.get("textHighlightText"), "TextArea.background", table.get("window"), "TextArea.foreground", table.get("textText"), "TextArea.font", monospacedPlain12, "TextArea.border", multilineTextBorder, "TextArea.keyBindings", multilineBindings, "TextPane.caretForeground", black, "TextPane.inactiveForeground", table.get("textInactiveText"), "TextPane.selectionBackground", lightGray, "TextPane.selectionForeground", table.get("textHighlightText"), "TextPane.background", white, "TextPane.foreground", table.get("textText"), "TextPane.font", serifPlain12, "TextPane.border", multilineTextBorder, "TextPane.keyBindings", multilineBindings, "EditorPane.caretForeground", red, "EditorPane.inactiveForeground", table.get("textInactiveText"), "EditorPane.selectionBackground", lightGray, "EditorPane.selectionForeground", table.get("textHighlightText"), "EditorPane.background", white, "EditorPane.foreground", table.get("textText"), "EditorPane.font", serifPlain12, "EditorPane.border", multilineTextBorder, "EditorPane.keyBindings", multilineBindings, "ScrollBar.background", scrollBarTrack, "ScrollBar.foreground", table.get("control"), "ScrollBar.track", scrollBarTrack, "ScrollBar.trackHighlight", table.get("controlDkShadow"), "ScrollBar.thumb", table.get("control"), "ScrollBar.thumbHighlight", table.get("controlHighlight"), "ScrollBar.thumbDarkShadow", table.get("controlDkShadow"), "ScrollBar.thumbLightShadow", table.get("controlShadow"), "ScrollBar.border", null, "ScrollPane.border", scrollPaneBorder, "ScrollPane.font", dialogPlain12, "ScrollPane.background", table.get("control"), "ScrollPane.foreground", table.get("controlText"), "ScrollPane.viewportBorder", null, "Slider.border", null, "Slider.foreground", table.get("control"), "Slider.background", table.get("control"), "Slider.highlight", table.get("controlHighlight"), "Slider.shadow", table.get("controlShadow"), "Slider.focus", table.get("controlDkShadow"), "SplitPane.background", table.get("control"), "SplitPane.highlight", table.get("controllHighlight"), "SplitPane.shadow", table.get("controlShadow"), "SplitPane.border", splitPaneBorder, "SplitPane.dividerSize", new Integer(5), "TabbedPane.font", dialogPlain12, "TabbedPane.tabBackground", table.get("control"), "TabbedPane.tabForeground", table.get("controlText"), "TabbedPane.tabHighlight", table.get("controlHighlight"), "TabbedPane.tabShadow", table.get("controlShadow"), "TabbedPane.tabDarkShadow", table.get("controlDkShadow"), "TabbedPane.focus", black, "Table.font", dialogPlain12, "Table.foreground", table.get("controlText"), "Table.background", table.get("window"), "Table.selectionForeground", table.get("textHighlightText"), "Table.selectionBackground", table.get("textHighlight"), "Table.gridColor", gray, "Table.focusCellHighlightBorder", focusCellHighlightBorder, "Table.focusCellBackground", table.get("window"), "Table.focusCellForeground", table.get("controlText"), "Table.scrollPaneBorder", tableScrollPaneBorder, "TableHeader.font", dialogPlain12, "TableHeader.foreground", table.get("controlText"), "TableHeader.background", table.get("control"), "TableHeader.cellBorder", BorderFactory.createRaisedBevelBorder(), "TitledBorder.font", dialogPlain12, "TitledBorder.titleColor", table.get("controlText"), "TitledBorder.border", titledBorderBorder, "ToolBar.border", toolBarBorder, "ToolBar.background", table.get("control"), "ToolBar.foreground", table.get("controlText"), "ToolBar.font", dialogPlain12, "ToolBar.dockingColor", table.get("control"), "ToolBar.floatingColor", table.get("control"), "ToolBar.dockingBorderColor", red, "ToolBar.floatingBorderColor", darkGray, "ToolTip.font", sansSerifPlain12, "ToolTip.border", toolTipBorder, "ToolTip.background", table.get("info"), "ToolTip.foreground", table.get("infoText"), "Tree.background", white, "Tree.font", dialogPlain12, "Tree.hash", gray, "Tree.textSelectionColor", white, "Tree.textNonSelectionColor", black, "Tree.borderSelectionColor", black, "Tree.backgroundSelectionColor", treeSelection, "Tree.backgroundNonSelectionColor", white, "Tree.openIcon", LookAndFeel.makeIcon(this.getClass(), "icons/TreeOpen.gif"), "Tree.closedIcon", LookAndFeel.makeIcon(this.getClass(), "icons/TreeClosed.gif"), "Tree.leafIcon", LookAndFeel.makeIcon(this.getClass(), "icons/TreeLeaf.gif"), "Tree.expandedIcon", null, "Tree.collapsedIcon", null, "ProgressBar.font", dialogPlain12, "ProgressBar.foreground", table.get("textHighlight"), "ProgressBar.background", table.get("control"), "ProgressBar.border", progressBarBorder, "ProgressBar.cellLength", new Integer(1), "ProgressBar.cellSpacing", new Integer(0), "OptionPane.font", dialogPlain12, "OptionPane.background", table.get("control"), "OptionPane.foreground", table.get("controlText"), "OptionPane.border", optionPaneBorder, "OptionPane.errorIcon", LookAndFeel.makeIcon(this.getClass(), "icons/Error.gif"), "OptionPane.informationIcon", LookAndFeel.makeIcon(this.getClass(), "icons/Inform.gif"), "OptionPane.warningIcon", LookAndFeel.makeIcon(this.getClass(), "icons/Warn.gif"), "OptionPane.questionIcon", LookAndFeel.makeIcon(this.getClass(), "icons/Question.gif"), "ColorChooser.font", dialogPlain12, "ColorChooser.background", table.get("control"), "ColorChooser.foreground", table.get("controlText"), "ColorChooser.selectedColorBorder", selectedColorBorder, "InternalFrame.icon", LookAndFeel.makeIcon(this.getClass(), "icons/JavaCup.gif"), "InternalFrame.border", internalFrameBorder, "InternalFrame.titleFont", dialogBold12, "InternalFrame.maximizeIcon", BasicIconFactory.createEmptyFrameIcon(), "InternalFrame.minimizeIcon", BasicIconFactory.createEmptyFrameIcon(), "InternalFrame.iconifyIcon", BasicIconFactory.createEmptyFrameIcon(), "InternalFrame.closeIcon", BasicIconFactory.createEmptyFrameIcon(), "DesktopIcon.border", null}; table.putDefaults(defaults); } protected void initSystemColorDefaults(UIDefaults table) { String[] systemColors = new String[]{"desktop", "#005C5C", "activeCaption", "#000080", "activeCaptionText", "#FFFFFF", "activeCaptionBorder", "#C0C0C0", "inactiveCaption", "#808080", "inactiveCaptionText", "#C0C0C0", "inactiveCaptionBorder", "#C0C0C0", "window", "#FFFFFF", "windowBorder", "#000000", "windowText", "#000000", "menu", "#C0C0C0", "menuText", "#000000", "text", "#C0C0C0", "textText", "#000000", "textHighlight", "#000080", "textHighlightText", "#FFFFFF", "textInactiveText", "#808080", "control", "#C0C0C0", "controlText", "#000000", "controlHighlight", "#FFFFFF", "controlLtHighlight", "#E0E0E0", "controlShadow", "#808080", "controlDkShadow", "#000000", "scrollbar", "#E0E0E0", "info", "#FFFFE1", "infoText", "#000000"}; this.loadSystemColors(table, systemColors); } protected void loadSystemColors(UIDefaults table, String[] systemColors) { for(int i = 0; i < systemColors.length; i += 2) { Color color = Color.black; try { color = Color.decode(systemColors[i + 1]); } catch (NumberFormatException var6) { ((Throwable)var6).printStackTrace(); } table.put(systemColors[i], new ColorUIResource(color)); } } }